package com.mb.ext.core.dao.impl.profit;

import javax.persistence.NoResultException;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import com.mb.ext.core.dao.AbstractBaseDAO;
import com.mb.ext.core.dao.profit.ProfitMerchantDAO;
import com.mb.ext.core.entity.profit.ProfitMerchantEntity;
import com.mb.framework.exception.DAOException;
import com.mb.framework.util.log.LogHelper;

@Repository("profitMerchantDAO")
@Qualifier("profitMerchantDAO")
public class ProfitMerchantDAOImpl extends AbstractBaseDAO<ProfitMerchantEntity> implements ProfitMerchantDAO
{
	private final LogHelper logger = LogHelper.getInstance(this.getClass().getName());

	/**
	 * Initializing Entity.
	 */
	public ProfitMerchantDAOImpl()
	{
		super();
		this.setEntityClass(ProfitMerchantEntity.class);
	}

	/**
	 * This method is used for inserting user information.
	 * 
	 * @param user
	 */
	@Override
	public void addProfitMerchant(ProfitMerchantEntity profitMerchantEntity) throws DAOException
	{
		save(profitMerchantEntity);
	}
	
	/**
	 * @param name
	 * @return 
	 * @throws Exception
	 */

	@Override
	public void updateProfitMerchant(ProfitMerchantEntity profitMerchantEntity) throws DAOException {
		update(profitMerchantEntity);
		
	}

	@Override
	public void deleteProfitMerchant(ProfitMerchantEntity profitMerchantEntity) throws DAOException {
		
		deletePhysical(profitMerchantEntity);
		
	}

	@Override
	public ProfitMerchantEntity getProfitMerchant()
			throws DAOException {
		ProfitMerchantEntity profitMerchantEntity = null;
		try {
			profitMerchantEntity = em.createQuery("select b from ProfitMerchantEntity b",ProfitMerchantEntity.class)
					.getSingleResult();
		} catch (NoResultException e) {
			logger.info("No record found for user: ");
		}
		return profitMerchantEntity;
	}
}
